﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuimini/css/public.css" rel="stylesheet" />
    <style>


    </style>
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <fieldset class="table-search-fieldset">
                <legend>计划材料汇总表</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form layui-form-pane" action="" lay-filter="example">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">开始日期</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="BeginDate" autocomplete="off" class="layui-input" name="BeginDate" readonly="readonly">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">结束日期</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="EndDate" autocomplete="off" class="layui-input" name="EndDate" readonly="readonly">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>
            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                </div>
            </script>
            <table class="layui-hide" id="table" lay-filter="currentTableFilter"></table>
            <script type="text/html" id="currentTableBar">
            </script>
        </div>
    </div>
    <script src="~/layui/layui.js"></script>
    <script src="~/layuimini/js/lay-config.js"></script>
    <script>
        layui.config({
            base: '/layui/extend/'
        }).extend({
            soulTable: 'soulTable'
        }).use(['form', 'table', 'laydate', 'soulTable'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                laydate = layui.laydate,
                soulTable = layui.soulTable;

            laydate.render({
                elem: '#BeginDate'
                , format: 'yyyy-MM-dd'
                , type: 'date'
                , trigger: 'click'
                , value: '@DateTime.Now.AddMonths(0).ToString("yyyy-MM-01")'
            });
            laydate.render({
                elem: '#EndDate'
                , format: 'yyyy-MM-dd'
                 , type: 'date'
               , trigger: 'click'
                 , value: '@DateTime.Now.AddMonths(0).ToString("yyyy-MM-dd")'
            });

        table.render({
            elem: '#table',
            method: 'post',
            url: '@Url.Action("JiHuaOrderReportForBill3Async", "Bill3")',
            request: {
                pageName: 'PageIndex' //页码的参数名称，默认：page
               , limitName: 'PageSize' //每页数据量的参数名，默认：limit
            },
            where: {
                BeginDate: form.val('example').BeginDate,
                EndDate: form.val('example').EndDate,
            },
            cellMinWidth:120,
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print'],
            cols: [[
                { type: "checkbox", width: 50 },
                { type: 'numbers', title: '序号', width: 50 },
                { field: 'ID', title: 'ID', width: 100, hide: true },
                { field: 'Code', title: '计划号' },
                { field: 'GoodsModel', title: '产品型号' },
                { field: 'Number', title: '产品批次号' },
                { field: 'DengJi', title: '质量等级' },
                { field: 'HeTongQty', title: '合同数量' },
                { field: 'JiHuaQty', title: '计划数量' },

                { field: '座Model', title: '管座型号' },
                { field: '座ZhiZhaoChangShang', title: '管座厂商' },
                { field: '座HuoYuanHao', title: '管座货源号' },
                { field: '座JianYanPiHao', title: '管座检验号' },
                { field: '座LingQty', title: '管座数量' },

                { field: '帽Model', title: '管帽型号' },
                { field: '帽ZhiZhaoChangShang', title: '管帽厂商' },
                { field: '帽HuoYuanHao', title: '管帽货源号' },
                { field: '帽JianYanPiHao', title: '管帽检验号' },
                { field: '帽LingQty', title: '管帽数量' },

                { field: '芯片1Model', title: '芯片1型号' },
                { field: '芯片1ZhiZhaoChangShang', title: '芯片1厂商' },
                { field: '芯片1HuoYuanHao', title: '芯片1货源号' },
                { field: '芯片1JianYanPiHao', title: '芯片1检验号' },
                { field: '芯片1LingQty', title: '芯片1数量' },

                { field: '芯片2Model', title: '芯片2型号' },
                { field: '芯片2ZhiZhaoChangShang', title: '芯片2厂商' },
                { field: '芯片2HuoYuanHao', title: '芯片2货源号' },
                { field: '芯片2JianYanPiHao', title: '芯片2检验号' },
                { field: '芯片2LingQty', title: '芯片2数量' },

                { field: '芯片3Model', title: '芯片3型号' },
                { field: '芯片3ZhiZhaoChangShang', title: '芯片3厂商' },
                { field: '芯片3HuoYuanHao', title: '芯片3货源号' },
                { field: '芯片3JianYanPiHao', title: '芯片3检验号' },
                { field: '芯片3LingQty', title: '芯片3数量' },

                { field: '芯片4Model', title: '芯片4型号' },
                { field: '芯片4ZhiZhaoChangShang', title: '芯片4厂商' },
                { field: '芯片4HuoYuanHao', title: '芯片4货源号' },
                { field: '芯片4JianYanPiHao', title: '芯片4检验号' },
                { field: '芯片4LingQty', title: '芯片4数量' },

                { field: '芯片5Model', title: '芯片5型号' },
                { field: '芯片5ZhiZhaoChangShang', title: '芯片5厂商' },
                { field: '芯片5HuoYuanHao', title: '芯片5货源号' },
                { field: '芯片5JianYanPiHao', title: '芯片5检验号' },
                { field: '芯片5LingQty', title: '芯片5数量' },

                { field: '芯片6Model', title: '芯片6型号' },
                { field: '芯片6ZhiZhaoChangShang', title: '芯片6厂商' },
                { field: '芯片6HuoYuanHao', title: '芯片6货源号' },
                { field: '芯片6JianYanPiHao', title: '芯片6检验号' },
                { field: '芯片6LingQty', title: '芯片6数量' },

                { field: 'TouQty', title: '投入数' },
                { field: 'JiaoFuQty', title: '下传数' },
                { field: 'FailQty', title: '废品数' },
                { field: 'ChengPinLv', title: '成品率' },
                { field: 'BillJiaoFuDate', title: '下传时间' },
            ]],
            limits: [10, 20, 30, 50, 100, 100000000],
            limit: 20,
            page: true,
            //skin: 'line',
            //totalRow: true,
            height: 'full-170',
            size:'sm',
        });


        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            RefreshTable();
            return false
        });

        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                var index = layer.open({
                    title: '添加流程卡',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: false,
                    area: ['1050px', '650px'],
                    content: '@Url.Action("IndexEdit", "Bill3")',
                    end: function () {
                        RefreshTable();

                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'delete') {  // 监听删除操作
                var checkStatus = table.checkStatus('table')
                    , data = checkStatus.data;
                if (data.length == 0) {
                    layer.msg('请选择您要删除的数据！', { icon: 5, time: 2000 });
                    return;
                }

                var arr = [];
                for (var i = 0; i < data.length; i++) {
                    arr.push(data[i].ID);
                }

                var ids = arr.join(",");


                layer.confirm('您确定要删除所选数据吗', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("IndexDelAsync", "Bill3")',
                        type: "post",
                        dataType: "json",
                        data: { IDs: ids },
                        success: function (data) {
                            //Info,Success,Warning,Error
                            var type = data.Type;
                            if (type == 1) {
                                layer.msg(data.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(data.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } else if (obj.event === 'export') {  // 监听删除操作
                soulTable.export('table', {
                    filename: '二车间.xlsx'
                });
            }
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {

                var index = layer.open({
                    title: '修改流程卡',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: false,
                    area: ['1050px', '650px'],
                    content: '@Url.Action("IndexEdit", "Bill3")' + '?ID=' + data.ID,
                    end: function () {
                        RefreshTable();
                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if (obj.event === 'delete') {
                layer.confirm('您确定要删除所选数据吗', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("ModifyIndexStateAsync", "Bill3")',
                        type: "post",
                        dataType: "json",
                        data: { ID: data.ID ,State:3},
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } else if (obj.event === 'details') {
                miniTab.openNewTabByIframe({
                    href: '@Url.Action("DetailsList", "Bill3")' + '?ID=' + data.ID,
                    title: "流程卡详情",
                });
                return false;
            } else if (obj.event === 'jiaofu') {
                miniTab.openNewTabByIframe({
                    href: '@Url.Action("JiaoFuList", "Bill3")' + '?ID=' + data.ID,
                    title: "流程卡交付详情",
                });
                return false;
            } else if (obj.event === 'touchan') {
                layer.confirm('投产后不能修改流卡信息，是否继续？', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("ModifyIndexStateAsync", "Bill3")',
                        type: "post",
                        dataType: "json",
                        data: { ID: data.ID,State:1 },
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } else if (obj.event === 'wancheng') {
                layer.confirm('确认此流程卡工序全部完成？', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("ModifyIndexStateAsync", "Bill3")',
                        type: "post",
                        dataType: "json",
                        data: { ID: data.ID, State: 2 },
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            }
        });
        function RefreshTable() {
            table.reload('table', {
                where: {
                    BeginDate: form.val('example').BeginDate,
                    EndDate: form.val('example').EndDate,

                }
            }, 'data');

        }

    });
    </script>
</body>
</html>